//
//  IDDError+LocalCache.m
//  ComJia
//
//  Created by Aslan on 17/02/2017.
//  Copyright © 2017 ComJia. All rights reserved.
//

#import "IDDError+LocalCache.h"

NSString *const IDDErrorCacheDomain = @"com.IDDKit.cacheErrorDomain";

@implementation IDDError (LocalCache)

+ (IDDError *)cacheErrorWithCode:(NSUInteger)code callstack:(NSArray *)callstack underlyingError:(NSError *)underlyingError
{
    NSArray *description = @[@"未知错误", /* IDDErrorCacheDomainUnknownError */
                             @"缓存对象为空", /* IDDErrorCacheDomainSetCacheToNil */
                             @"删除缓存文件失败", /* IDDErrorCacheDomainRemoveItem */
                             @"与目标文件同名的目录已经存在", /* IDDErrorCacheDomainExistingDirectory */
                             @"文件系统错误", /* IDDErrorCacheDomainFilesystemError */
                             @"不支持的缓存对象", /* IDDErrorCacheDomainUncacheableObject */
                             @"归档对象失败", /* IDDErrorCacheDomainArchiveFailure */
                             @"反归档对象失败", /* IDDErrorCacheDomainUnarchiveFailure */];
    if (code >= [description count]) {
        code = IDDErrorCacheDomainUnknownError;
    }
    return [[IDDError alloc] initWithDomain:IDDErrorCacheDomain code:code userDescription:description[code] callstack:callstack underlyingError:underlyingError];
}

@end
